// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"

class USphereComponent;
class USoundCue;
class UStaticMeshComponent;
class UNiagaraComponent;
class UNiagaraSystem;


UCLASS()
class BLASTER_API APickup : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	APickup();
	virtual void Tick(float DeltaTime) override;
	virtual void Destroyed() override;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	UFUNCTION()
	virtual void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
	                             UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
	                             const FHitResult& SweepResult);
	UPROPERTY(EditAnywhere)
	float BaseTurnRate{45.f};
private:
	UPROPERTY(EditAnywhere)
	USphereComponent* OverlapSphere;
	UPROPERTY(EditAnywhere)
	USoundCue* PickupSound;

	UPROPERTY(EditAnywhere)
	UStaticMeshComponent* PickupMesh;

	UPROPERTY(VisibleAnywhere)
	UNiagaraComponent* PickupEffectComponent;
	UPROPERTY(EditAnywhere)
	UNiagaraSystem* PickupEffect;
	//不让Actor刚产生是就绑定重叠事件，让角色生成0.25秒后再绑定，如果在0.25秒之前有Actor到碰撞事件产生区域，则在0.25秒后
	//此Actor绑定重叠事件，此时先前来的Actor将不会触发重叠事件
	FTimerHandle BindOverlapTimer;
	float BindOverlapTime{0.25f};
	void BindOverlapTimerFinished();
};
